<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>

    <script src="${baseUrl!}/static/huihuo/js/jquery-1.8.3.min.js" type="text/javascript"></script>
</head>
<body>

<form class="form-horizontal" style="line-height: 1.5em;">
    <div class="form-group">
        <label for="email" class="col-sm-2 control-label">邮箱</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="email" value="${email!}" placeholder="邮箱">
        </div>
    </div>
    <div class="form-group">
        <label for="password" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-6">
            <input type="password" class="form-control" id="password" placeholder="密码">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <div class="checkbox">
                <label>
                    <input type="checkbox" id="remember_me" value="1"> 记住邮箱
                    &nbsp;&nbsp;&nbsp;&nbsp;<a href="${baseUrl!}/search_pass">忘记密码？</a>
                </label>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" id="login" class="btn btn-primary">登录</button>
            <a href="${baseUrl!}/qqlogin" class="btn btn-success">&nbsp;&nbsp;&nbsp;通过 QQ 登录&nbsp;&nbsp;&nbsp;</a>
        </div>
    </div>
</form>

</body>
</html>

<script type="text/javascript">
    $(function() {
        $("#login").click(function(){
            if($("#email").val().trim() == "") {
                alert("请输入邮箱");
            } else {
                $.ajax({
                    url: "${baseUrl!}/login",
                    async: false,
                    cache: false,
                    type: 'post',
                    dataType: "json",
                    data: {
                        email: $("#email").val(),
                        password: $("#password").val()
                    },
                    success: function (data) {
                        if (data.code == '200') {
                            location.href = "${baseUrl!}/";
                        } else {
                            alert(data.description);
                        }
                    }
                });
            }
        });
    });
</script>